<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
</head>

<body>
    <!-- 1. 先准备一个容器 -->
    <div id="app">
        <p>{{msg}}</p>
        <button @click="reverseString">翻转世界</button>
    </div>
    <!-- 2. 引框架 -->
    <script src="./vue.js"></script>
    <script>
        // 3.初始化vue实例对象
        const vm = new Vue({
            el: "#app",
            data: {
                msg: "Hello,world",

            },
            methods: {
                reverseString() {
                    // 用新的字符串来接收翻转结果
                    const newMsg = this.msg.split("").reverse().join("")
                    //  把最新的字符串赋值给msg
                    this.msg = newMsg
                }
            }
        });
    </script>
</body>

</html>